unit frmMain;

interface

uses
  Winapi.Windows,
  Winapi.Messages,
  System.SysUtils,
  System.Variants,
  System.Classes,
  Vcl.Graphics,
  Vcl.Controls,
  Vcl.Forms,
  Vcl.Dialogs,
  Vcl.Imaging.Jpeg,

  GLS.Scene,
  GLS.Objects,
  GLS.Cadencer,
  GLS.Texture,
  GLS.SceneViewer,
  GLS.ProjectedTextures,
  GLS.VectorTypes,
  GLS.VectorGeometry,
  GLS.Material,
  GLS.Coordinates,
  GLS.BaseClasses;

type
  TMain = class(TForm)
    SceneViewer: TGLSceneViewer;
    Scene: TGLScene;
    MaterialLibrary: TGLMaterialLibrary;
    Cadencer: TGLCadencer;
    Camera: TGLCamera;
    WallLeft: TGLPlane;
    WallFront: TGLPlane;
    WallRight: TGLPlane;
    Floor: TGLPlane;
    Light0: TGLLightSource;
    Room: TGLDummyCube;
    ProjectedTextures: TGLProjectedTextures;
    FlashLightTE: TGLTextureEmitter;
    FlashLight: TGLDummyCube;
    Ceiling: TGLPlane;
    Cube1: TGLCube;
    procedure SceneViewerMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure CadencerProgress(Sender: TObject; const deltaTime,
      newTime: Double);
  private
  public
  end;

var
  Main: TMain;

implementation

{$R *.dfm}

procedure TMain.SceneViewerMouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
var
  V: TVector4f;
begin
  SetVector(V,SceneViewer.Buffer.ScreenToWorld(X,Y));
  V := VectorSubtract(Camera.AbsolutePosition,V);
  NormalizeVector(V);
  FlashLight.Direction.SetVector(V);
end;

procedure TMain.CadencerProgress(Sender: TObject; const deltaTime,
  newTime: Double);
begin
  Cube1.Turn(deltaTime * 20);
end;

end.
